

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>{:site_name()}后台管理-登陆</title>
    <meta name="keywords" content="TopAdmin 基于thinkphp6,thinkphp,layui,easywechat框架,框架,组件">
    <meta name="description" content="TopAdmin 是一款采用 layui开发的极简后台管理框架 基于thinkphp6 ,easywechat,开发的cms后台管理系统,thinkphp,cms,php后台管理系统,cms,cms系统,restful api,thinkphp后台管理系统">
    <link rel="stylesheet" href="/static/libs/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/css/main.css" />
    {:token_meta()}
</head>

<body class="admin-login-background">
<div id="mydiv">
    <div class="login-main">
        <div class="layui-elip">{:config('site_name')}管理系统<span class="bg1"></span><span class="bg3"></span><span class="bg2"></span><span class="bg4"></span></div>
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-input-inline input-item">
                    <label class="layui-icon layui-icon-username"></label>
                    <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="账号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline input-item">
                    <label class="layui-icon layui-icon-password"></label>
                    <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline input-item verify-box">
                    <label class="layui-icon layui-icon-vercode"></label>
                    <input type="text" name="captcha" lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
                    <img  id="captchaPic" src="{:url('verify')}?{:time()}" alt="captcha" onclick="this.src='{:url("verify")}?'+'id='+Math.random()"/>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline input-item">
                    <input type="checkbox" name="keeplogin" title="保持会话" lay-skin="primary">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline login-btn">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="login">登 入</button>
                </div>
            </div>
            <div class="copyright">
                © 2018-2020 <a href="https://dzd.wxinw.com" target="_blank">{:site_name()}</a> All Rights Reserved.
            </div>
        </form>
    </div>
</div>
<script src="/static/libs/jquery/jquery.min.js" charset="utf-8"></script>
<script src="/static/libs/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer;
        // 登录过期的时候，跳出ifram框架
        if (top.location != self.location) top.location = self.location;

        form.on('submit(login)', function (data) {
            data = data.field;

            if (data.username == '') {
                layer.msg('用户名不能为空');
                return false;
            }
            if (data.password == '') {
                layer.msg('密码不能为空');
                return false;
            }
            if (data.captcha == '') {
                layer.msg('验证码不能为空');
                return false;
            }

            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                method:'post',
                data:data,
                success:function (res) {
                    if(res.code>0){
                        layer.msg(res.msg, function () {
                            window.location = "{:url('index/index')}";
                        });
                    }else{
                        layer.msg(res.msg);
                        $('#captchaPic').attr('src','{:url("verify")}?id='+Math.random());
                        return false;
                    }

                },fail:function (res) {
                    layer.msg(res.msg, function () {
                        $('#captchaPic').attr('src','{:url("verify")}?id='+Math.random());
                        return false;
                    });
                }
            });

            return false;
        });
    });
</script>
</body>
</html>

